import 'package:flutter/material.dart';

class KeyValueSegmentWidget extends StatelessWidget {
  final String keyText;
  final String valueText;
  final EdgeInsets padding;
  final Color? color;
  final double fontSize;
  final double borderRadius;

  const KeyValueSegmentWidget({
    Key? key,
    required this.keyText,
    required this.valueText,
    this.color,
    this.fontSize = 10.0,
    this.padding = const EdgeInsets.symmetric(vertical: 2, horizontal: 4),
    this.borderRadius = 4.0,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    return Container(
      decoration: BoxDecoration(
        border: Border.all(color: color ?? theme.primaryColor),
        borderRadius: BorderRadius.circular(borderRadius),
      ),
      clipBehavior: Clip.antiAlias,
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          Container(
            padding: padding,
            child: Text(
              keyText,
              style: TextStyle(
                fontSize: fontSize,
                color: Colors.white,
              ),
            ),
            color: color ?? theme.primaryColor,
          ),
          Padding(
            padding: padding,
            child: Text(
              valueText,
              style: TextStyle(
                fontSize: fontSize,
                color: color ?? theme.primaryColor,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
